<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
      list-style: none;
    }
    html,body{
      background-color: #000;
    }
    .box{
      width: 640px;
      height: 400px;
      border: 2px solid white;
      margin: 40px auto;
    }
    .box ul{
      width: 100%;
      height: 100%;
      border: 5px solid #000;
      box-sizing: border-box;
    }
    .box li{
      float: left;
      padding: 3px 5px;
    }
    img{
      width:100%;
      height: 100%;
    }
    .active{
      background-color: #000;
      opacity: 0.3;
    }
  </style>
</head>
<body>
  <div class="box">
    <ul>
      <li><img src="images/01.jpg" alt=""></li>
      <li><img src="images/02.jpg" alt=""></li>
      <li><img src="images/03.jpg" alt=""></li>
      <li><img src="images/04.jpg" alt=""></li>
      <li><img src="images/05.jpg" alt=""></li>
      <li><img src="images/06.jpg" alt=""></li>
    </ul>
  </div>
  <script src="../../jquery-1.12.4.min.js"></script>
  <script>
    console.log($('li'))
    $('li').mouseenter(function(){
      $(this).removeClass('active').siblings().addClass('active');
    });
    //方法一
    $('li').mouseleave(function(){
      $(this).siblings().removeClass('active');;
    })
    //方法二
    $('.box').mouseleave(function(){
      $('li').each(function(i,e){
        $(e).removeClass('active');
      });
    });
    //方法三
    $('.box').mouseleave(function(){
      console.log(1)
     $('li').removeClass('active');
    });
  </script>
</body>
</html>